import 'package:flutter/material.dart';
class homePage extends StatefulWidget{
  _homePage createState() => _homePage();
}
class _homePage extends State<homePage>{
  List list = new List();
  Widget build(BuildContext context){
    return ListView(
      children: <Widget>[
        Column(
          children: this.list.map((v){
            return ListTile(
              title: Text(v),
            );
          }).toList(),
        ),
        SizedBox(height: 50,),
        RaisedButton(
          child: Text('增加数据'),
          onPressed: (){
            setState(() {
             this.list.add('新增数据1');
            });
          },
        ),
        SizedBox(
          height:30,
        ),
        Center(

          // mainAxisAlignment: MainAxisAlignment.center,
          child: formDetail()
        ),
      ],
    );
  }
}
class formDetail extends StatefulWidget{
  _formDetail createState()=> _formDetail();
}
class _formDetail extends State<formDetail>{
  var username = new TextEditingController();//编辑器初始化赋值
  bool isCheck = true;
  var sex = 1;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    // username.text = "初始值";
    setState(() {
     username.text = "初始值"; 
    });
  }

  @override
  Widget build(BuildContext context){
    return Column(
            children: <Widget>[
              Container(
                width: 300,
                child: TextField(
                  controller: username,
                  onChanged: (context){
                    print(context);
                    setState(() {
                     username.text = context;
                    });
                  },
                  decoration: InputDecoration(
                    border: OutlineInputBorder(),
                    hintText: "请输入账号"
                  ),
                  
                ),
              ),
              RaisedButton(
                child: Text("登录"),
                color: Colors.amberAccent,
                onPressed: (){
                  print(this.username.text);
                },
              ),
              // Row(
              //   children: <Widget>[
              //     Checkbox(
              //       value: this.isCheck,
              //       onChanged: (v){
              //         print(v);
              //         setState(() {
              //          this.isCheck = v; 
              //         });
              //       },
              //     ),
              //     Text("餐具")
              //   ],
              // ),
              CheckboxListTile(
                value: this.isCheck,
                onChanged: (r){
                  setState(() {
                   this.isCheck = r; 
                  });
                },
                title: Text("一级标题一级标题一级标题一级标题"),
                subtitle: Text("二级标题二级标题二级标题二级标题二级标题二级标题二级标题"),
                secondary: Icon(Icons.ac_unit),
              ),
              Row(
                children: <Widget>[
                  Text("男:"),
                  Radio(
                    value: 1,
                    onChanged: (r){
                      print(r);
                      setState(() {
                       this.sex = r; 
                      });
                    },
                    groupValue: this.sex,
                  ),
                  Text("女:"),
                  Radio(
                    value: 2,
                    onChanged: (v){
                      print(v);
                      setState(() {
                       this.sex = v; 
                      });
                    },
                    groupValue: this.sex,
                  )
                ],
              )
            ],
          );
  }
}